package com.kd.juhaowan.ui;

import android.content.Intent;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallbackProxy;
import com.hjq.toast.ToastUtils;
import com.kd.juhaowan.R;
import com.kd.juhaowan.http.api.LogoffConfirmApi;
import com.kd.juhaowan.http.model.HttpData;
import com.kd.juhaowan.http.model.LogoffResult;

import butterknife.BindView;
import butterknife.OnClick;

public class LogoffFinalActivity extends BaseActivity {


    @BindView(R.id.activity_title)
    TextView titleView;
    @BindView(R.id.regist_checkbox)
    CheckBox mCheckBox;


    @Override
    protected void reInitDate() {
//     initData();
    }
    //    public static boolean needRefresh=true;
    private void initData(){
//        needRefresh =false;


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }



    @Override
    protected void onResume() {
        super.onResume();
//        if(needRefresh)initData();
    }

    private void setView(){


    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        titleView.setText("确认注销");
//        setContentView(R.layout.activity_account_login);

    }
    @OnClick(R.id.actvity_back)
    public void onBackClick(){
        finish();
    }


    @OnClick({R.id.logoff_final_tip,R.id.logoff_final_tip2})
    public void ontipClick(){
        Intent in=new Intent(LogoffFinalActivity.this,DocumentActivity.class);
        in.putExtra("question_id","27");
        startActivity(in);
    }

    @OnClick(R.id.logoff_account_confirm)
    public void onPasswordClick(){
        if(!mCheckBox.isChecked()){
            ToastUtils.show("请阅读并同意协议");
            return;
        }

        LogoffResult re= (LogoffResult)getIntent().getSerializableExtra("model");

            EasyHttp.post(this).api(new LogoffConfirmApi(re.getToken())).request(new HttpCallbackProxy<HttpData<LogoffResult>>(this){
                @Override
                public void onHttpSuccess(HttpData<LogoffResult> result, boolean cache) {
                    super.onHttpSuccess(result, cache);
                   ToastUtils.show("提交成功");
                   setResult(RESULT_OK);
                   finish();
                }
            });


    }
    @Override
    protected int getViewLayoutResourceId() {
        return R.layout.activity_logoff_final;
    }



}
